template <class T> class reference_wrapper;
| member type | definition |
|---|---|
| type | The template parameter (T) |
| result_type | If T is a pointer to function or to member function type: the return type of T. If T is a class, and has a result_type member: T::result_type.Otherwise, not defined. |
| argument_type | If T is a function type or a pointer to function type taking a single argument: the type of the argument taken by T. If T is a pointer to member function: the class type of which T is a member (with the same const/volatile qualification as the member function). If T is a class, and has an argument_type member: T::argument_type.Otherwise, not defined. |
| first_argument_type | If T is a function type or a pointer to function type taking two arguments: the type of the first argument taken by T. If T is a pointer to member function taking a single argument: the class type of which T is a member (with the same const/volatile qualification as the member function). If T is a class, and has a first_argument_type member: T::first_argument_type.Otherwise, not defined. |
| second_argument_type | If T is a function type or a pointer to function type taking two arguments: The type of the second argument taken by T. If T is a pointer to member function taking a single argument: the argument taken by T. If T is a class, and has a second_argument_type member: T::second_argument_type.Otherwise, not defined. |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// reference_wrapper example:
#include <iostream> // std::cout
#include <functional> // std::reference_wrapper
int main () {
int a(10),b(20),c(30);
// an array of "references":
std::reference_wrapper<int> refs[] = {a,b,c};
std::cout << "refs:";
for (int& x : refs) std::cout << ' ' << x;
std::cout << '\n';
return 0;
}
refs: 10 20 30